﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pgAdminUsuarios.aspx.cs" Inherits="EGuayas.Web.Usuario.pgAdminUsuarios" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link  href="~/Resources/css/Style.css"  rel="stylesheet" />
    <!-- Load Ext JS --> 
    <script src="../Resources/js/Global.js"></script>   
</head>
<body>  
    <form id="Form1" runat="server"> 
        <ext:ResourceManager ID="pgIdCategManager" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
                 <Items>
                           <%-- Hidden almacena IdPageSession  --%>
                           <ext:Hidden Text="" ID="hddIdPageSession" runat="server"></ext:Hidden>
                           <ext:FormPanel  runat="server" Region="Center" Layout="VBoxLayout">
                                    <LayoutConfig>
                                            <ext:VBoxLayoutConfig Align="Stretch" />
                                    </LayoutConfig>
                                    <Items> 
                                      <ext:FormPanel
                                        ID="frmSettings"
                                        runat ="server" 
                                        Title ="Usuarios" 
                                        Icon  ="GroupEdit"
                                        Margins ="5 5 5 5" 
                                        Flex    ="1"
                                        AutoScroll="true"
                                        Layout  ="FormLayout"
                                        BodyBorder  ="0">  
                                        <Items>
                                             <%-- Hidden almacena Id Roles de Usuario  --%>
                                             <ext:Hidden Text="" ID="hddRolCodigoPromotor"  runat="server"></ext:Hidden> 
                                             <ext:Hidden Text="" ID="hddRolCodigoTecnico"  runat="server"></ext:Hidden> 
                                             <ext:Hidden Text="" ID="hddRolCodigoTecnicoL"  runat="server"></ext:Hidden> 
                                             <ext:Hidden Text="" ID="hddRolCodigoAdminis"  runat="server"></ext:Hidden>
                                             <ext:Hidden Text="" ID="hddRolCodigoJefe"  runat="server"></ext:Hidden> 
                                             <ext:Hidden Text="" ID="hddRolCodigoJefeL"  runat="server"></ext:Hidden> 
                                             <ext:Hidden Text="" ID="hddRolCodigoConsultor"  runat="server"></ext:Hidden>
                                             <ext:Hidden Text="" ID="hddRolCodigoDirector"  runat="server"></ext:Hidden>   
                                             <ext:Hidden Text="" ID="hddRolCodigoSubDirector"  runat="server"></ext:Hidden>          
                                             <ext:Panel ID="pnlBusqueda" runat="server" Height="90px" Region="North" BodyPadding="6" Header="False" ButtonAlign="Center"   Collapsible="true">
                                                <Items>
                                                    <ext:Panel ID="panC1" runat="server" Layout="ColumnLayout" Border="false" >
                                                        <Items>
                                                            <ext:Panel ID="panC1Col1" runat="server" ColumnWidth=".33" Border="false"  >
                                                                <Items>
                                                                    <ext:TextField ID="txtNombre" runat="server" FieldLabel="Nombre"></ext:TextField>
                                                                
                                                                </Items>
                                                            </ext:Panel>
                                                            <ext:Panel ID="panC1Col2" runat="server" ColumnWidth=".33" Border="false" >
                                                                <Items>
                                                                    <ext:TextField ID="txtApellido" runat="server" FieldLabel="Apellido"></ext:TextField>
                                                                
                                                                </Items>
                                                            </ext:Panel>
                                                            <ext:Panel ID="panC1Col3" runat="server" ColumnWidth=".33" Border="false"  >
                                                                <Items>
                                                                    <ext:ComboBox ID="cbbRol" runat="server" FieldLabel="Rol" ValueField="Codigo" DisplayField="Nombre">
                                                                        <Store>
                                                                            <ext:Store runat="server" ID="stoRol">
                                                                                <Model>
                                                                                    <ext:Model ID="Model1" runat="server" IDProperty="Codigo">
                                                                                        <Fields>
                                                                                            <ext:ModelField Name="Codigo"></ext:ModelField>
                                                                                            <ext:ModelField Name="Nombre"></ext:ModelField>
                                                                                        </Fields>
                                                                                    </ext:Model>
                                                                                </Model>
                                                                            </ext:Store>
                                                                        </Store>
                                                                        <Triggers>
                                                                            <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                                                        </Triggers>
                                                                        <Listeners>
                                                                            <Select Handler="this.getTrigger(0).show();" />
                                                                            <BeforeQuery Handler="this.getTrigger(0)[this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                                                            <TriggerClick Handler="if (index == 0) { 
                                                                               this.clearValue(); 
                                                                               this.getTrigger(0).hide();}" />
                                                                        </Listeners>
                                                                  
                                                                    </ext:ComboBox>
                                                                </Items>
                                                            </ext:Panel>
                                                        </Items>
                                                    </ext:Panel>
                                                </Items>
                                                <Buttons>
                                                    <ext:Button runat="server" ID="btnBuscarExpedientesLic" Text="Buscar">
                                                        <DirectEvents>
                                                            <Click OnEvent="btnBuscarUsuarios_Click" Before="pgFn.setParameDinamic();">
                                                                <ExtraParams>
                                                                    <ext:Parameter Name="Nombre" Value="#{txtNombre}.getValue()" Mode="Raw"/>
                                                                    <ext:Parameter Name="Apellido" Value="#{txtApellido}.getValue()" Mode="Raw"/>
                                                                    <ext:Parameter Name="Rol" Value="#{cbbRol}.getValue()==null?'':#{cbbRol}.getValue()" Mode="Raw"/>
                                                                 </ExtraParams>
                                                                <EventMask ShowMask="True"></EventMask>
                                                            </Click>
                                                        </DirectEvents>
                                                    </ext:Button>

                                                </Buttons>
                                            </ext:Panel>
                                             <ext:GridPanel
                                                    ID="gpDocumentosLoadUser"
                                                    runat="server" 
                                                    Flex="1"                                                                                     
                                                    Region="Center">
                                                    <Store>
                                                        <ext:Store ID="stoListaUsuarios" runat="server" >
                                                           <Model>
                                                                <ext:Model ID="modelUsuarios" runat="server" IDProperty="Id">
                                                                    <Fields>
                                                                            <ext:ModelField Name="Login" Type="String" />
                                                                            <ext:ModelField Name="FechaCreacion" Type="Date" />                                                                 
                                                                            <ext:ModelField Name="Clave" Type="String" />
                                                                            <ext:ModelField Name="Id" Type="String" />
                                                                            <ext:ModelField Name="Identificacion" Type="String" />
                                                                            <ext:ModelField Name="Nombre" Type="String" />
                                                                            <ext:ModelField Name="Apellido" Type="String" />
                                                                            <ext:ModelField Name="Direccion" Type="String" />
                                                                            <ext:ModelField Name="Email" Type="String" />
                                                                            <ext:ModelField Name="Estado" Type="String" />
                                                                            <ext:ModelField Name="PersonaId" Type="String" />
                                                                            <ext:ModelField Name="RolId" Type="String" />
                                                                            <ext:ModelField Name="ParroquiaId" Type="String" />
                                                                            <ext:ModelField Name="Rol" Type="String" /> 
                                                                            <ext:ModelField Name="RolCodigo" Type="String" />   
                                                                    </Fields>
                                                                </ext:Model>
                                                            </Model>                                      
                                                                                                                  
                                                        </ext:Store>
                                                        
                                                    </Store>
                                                    <ColumnModel ID="ColumnModel2" runat="server">
                                                        <Columns>
                                                            <ext:Column  runat="server" Text="Id" DataIndex="Id" Flex="1" Hidden="true"/>
                                                            <ext:Column  runat="server" Text="Nombre" DataIndex="Nombre" Flex="2"/>
                                                            <ext:Column  runat="server" Text="Apellido" DataIndex="Apellido" Flex="2"/>
                                                            <ext:Column  runat="server" Text="Rol" DataIndex="Rol"/>  
                                                            <ext:DateColumn runat="server" Text="Fecha" Width="95" DataIndex="FechaCreacion" Format="dd-m-yy"  Flex="2"/>
                                                            <ext:Column runat="server" Text="Activar/Desactivar" Align="Center">
                                                                            <Commands>
                                                                                <ext:ImageCommand CommandName="CmdActivo" Icon="UserTick" Text="Activo"> 
                                                                                    <ToolTip Text="Click para Desactivar"></ToolTip>                                                                             
                                                                                </ext:ImageCommand>
                                                                                <ext:ImageCommand CommandName="CmdDesactivo" Icon="UserAlert" Text="Inactivo">  
                                                                                       <ToolTip Text="Click para Activar"></ToolTip>                                                                               
                                                                                </ext:ImageCommand>
                                                                                <ext:ImageCommand CommandName="CmdText" Text="Inactivo" Icon="GroupGo" Disabled="true">                                                                                                                                                                
                                                                                </ext:ImageCommand>
                                                                            </Commands>
                                                                            <PrepareCommand Fn="pgFn.PrepareCommandGrid" />
                                                                            <Listeners>                                                                   
                                                                                   <Command Handler="pgFn.ImageCommandUdpateEstado(command,record.data);" >                                                                             
                                                                                   </Command>
                                                                            </Listeners>   
                                                            </ext:Column>                                                      
                                                            <ext:Column ID="Column1"  runat="server">
                                                                            <Commands>
                                                                                <ext:ImageCommand CommandName="Cmd" Icon="UserEdit" Text="Actualizar">
                                                                                    <ToolTip Text="Actualizar" />
                                                                                </ext:ImageCommand>
                                                                            </Commands>
                                                                       
                                                                            <Listeners>                                                                   
                                                                                  <Command Handler="pgFn.ShowViewDetailPanel(record,'MODIFICAR');" >                                                                             
                                                                               </Command>
                                                                            </Listeners>   
                                                            </ext:Column> 
                                                            <ext:Column ID="Column5"  runat="server">
                                                                            <Commands>
                                                                                <ext:ImageCommand CommandName="Delete" Icon="Cross" Text="Eliminar">
                                                                                    <ToolTip Text="Eliminar" />
                                                                                </ext:ImageCommand>
                                                                            </Commands>
                                                                       
                                                                            <Listeners>                                                                   
                                                                                   <Command Handler="pgFn.ShowViewDetailPanel(record,'ELIMINAR');" >
                                                                                   </Command>
                                                                            </Listeners>   
                                                            </ext:Column>   
                                                                                                                                       
                                                        </Columns>                                                    
                                                    </ColumnModel>
                                                    
                                                    <TopBar>
                                                    <ext:Toolbar ID="Toolbar1" runat="server">
	                                                    <Items>   
		                                                     <ext:SplitButton ID="SplitButton1" runat="server" Text="Agregar Usuario"  Icon="UserAdd">
			                                                    <Menu>
				                                                    <ext:Menu ID="Menu1" runat="server">
					                                                    <Items>
						                                                    <ext:MenuItem ID="MenuItem1" runat="server" Text="Administrador"  Url="pgAdmin.aspx?CodeRol=ADM"/>
                                                                            <ext:MenuItem ID="MenuItem6" runat="server" Text="Director"  Url="pgAdmin.aspx?CodeRol=DIRECTOR"/>
                                                                            <ext:MenuItem ID="MenuItem7" runat="server" Text="SubDirector"  Url="pgAdmin.aspx?CodeRol=SUBDIRECTOR"/>
						                                                    <ext:MenuItem ID="MenuItem2" runat="server" Text="Promotor"  Url="pgPromotor.aspx?tmp=1"/>
						                                                    <ext:MenuItem ID="MenuItem3" runat="server" Text="Tecnico"   Url="pgTecnico.aspx?tmp=1"/><%--?idPage=PGTecnicoOperaciones  --%>
                                                                            <ext:MenuItem ID="MenuItem4" runat="server" Text="Jefe Departamental"  Url="pgJefeDep.aspx?tmp=1"/><%--  ?idPage=PGJefeOperaciones   --%>
                                                                            <ext:MenuItem ID="MenuItem5" runat="server" Text="Consultor"  Url="pgConsultor.aspx?tmp=1"/>
					                                                    </Items>
					                                                    <Listeners>
					                                                       <Click Handler="pgFn.cargarTabNewUser(item,menuItem,e);"></Click>
					                                                    </Listeners>
				                                                    </ext:Menu>
				
			                                                    </Menu>
			                                                     <Listeners>
				 
			                                                     </Listeners>
		                                                    </ext:SplitButton>
                                                             <ext:Button runat="server" Text="Activar Promotor"   Icon="GroupGo">
                                                                 <Listeners>
                                                                     <Click Handler="pgFn.ShowActivarUsuario();"></Click>
                                                                 </Listeners>
                                                             </ext:Button>
                                                          <ext:ToolbarFill ID="ToolbarFill2" runat="server" /> 
                                                          
	                                                    </Items>
                                                    </ext:Toolbar>
                                                    </TopBar> 
                                                    <View>
		                                                <ext:GridView ID="GridView2" runat="server" StripeRows="true" />                   
		                                            </View>        
                                                    <BottomBar>
                                                         <ext:PagingToolbar ID="PagingToolbar1" runat="server" >
                                                            <Items>
                                                                <ext:Label ID="Label1" runat="server" Text="Filas por página:" />
                                                                <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                                                <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                                                    <Items>
                                                                        <ext:ListItem Text="5" />
                                                                        <ext:ListItem Text="10" />
                                                                        <ext:ListItem Text="15" />
                                                                        <ext:ListItem Text="20" />
                                                                        <ext:ListItem Text="25" />
                                                                        <ext:ListItem Text="30" />
                                                                        <ext:ListItem Text="35" />
                                                                        <ext:ListItem Text="40" />
                                                                        <ext:ListItem Text="45" />
                                                                        <ext:ListItem Text="50" />
                                                                    </Items>
                                                                    <SelectedItems>
                                                                        <ext:ListItem Value="10" />
                                                                    </SelectedItems>
                                                                    <Listeners>
                                                                        <Select Handler="#{gpDocumentosLoadUser}.store.pageSize = parseInt(this.getValue(), 10); #{gpDocumentosLoadUser}.store.load();" />
                                                                    </Listeners>
                                                                </ext:ComboBox>
                                                            </Items>
                  
                                                        </ext:PagingToolbar>
                                                    </BottomBar>     
                                                       <Features>
                                                    <ext:GridFilters runat="server" ID="GridFilters1" Local="true"  MenuFilterText="Filtrar por">
                                                        <Filters>
                                                            <ext:StringFilter DataIndex="Nombre" EmptyText="Nombre" />
                                                            <ext:StringFilter DataIndex="Apellido"  EmptyText="Apellido"/> 
                                                                <ext:DateFilter DataIndex="FechaCreacion" AfterText="Despues de" BeforeText="Antes de"  OnText="En">
                                                                <DatePickerOptions runat="server" TodayText="Ahora" />
                                                            </ext:DateFilter>                                                           
                                                        </Filters>
                                                    </ext:GridFilters>
                                                </Features>                                             
                                                </ext:GridPanel>
                                        </Items>
                                        </ext:FormPanel>            
                                        <ext:FormPanel
                                            ID        ="frmDetail"
                                            runat     ="server" 
                                            Flex      ="1" 
                                             Layout      ="FitLayout"
                                            BodyBorder ="0"                                
                                            Hidden   ="true">  
                                            <TopBar>
                                            <ext:Toolbar ID="Toolbar2" runat="server">
                                                <Items>
                                                  <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                                                    <ext:Button 
                                                        ID    ="btnForm"
                                                        runat ="server" 
                                                        Text  ="Ver Usuarios" 
                                                        Icon  ="ShapeSquareGo"
                                                        OnClientClick="pgFn._closeWinUserNew();">                                            
                                                        <Listeners>                     
                                                        </Listeners>
                                                    </ext:Button>
                                                  
                                                </Items>
                                            </ext:Toolbar>
                                </TopBar>
                                 <Items>  
                                           <ext:Hidden Text="" ID="hdId"   Name="Id" runat  ="server"></ext:Hidden>
                                           <ext:Hidden Text="" ID="hdRolId"  Name="RolId"  runat   ="server"></ext:Hidden>
                                           <ext:TabPanel ID="TabPanel1" runat="server" Region="Center"  TabPosition="Left" EnableTabScroll="true">
                                                <Items> 
                                                    <ext:Panel ID ="tab1FrmDetail" runat="server"  ButtonAlign ="Center" Title="Datos de usuario" Layout="AnchorLayout">
                                                            <Loader ID="Loader2"  Url="tabs/pgUndefined.aspx"   Mode="Frame"  AutoLoad="false" Scripts="true" DisableCaching="true" runat="server" >
                                                                <LoadMask ShowMask="true" />
                                                            </Loader>
                                                           
                                                    </ext:Panel>
                                                    </Items>
                                            </ext:TabPanel>                    
                                 </Items>
                           </ext:FormPanel>
                             </Items>
                       
                       <BottomBar>
                         <ext:StatusBar 
                                ID="StatusBar2" 
                                runat="server"
                                StatusAlign="Left">
                                <Items>                                
                                    <ext:ToolbarTextItem ID="ToolbarTextItem1" runat="server" Text="" Cls="ux-bold-text-item"  Margin="5"/>
                                </Items>
                            </ext:StatusBar>
                        </BottomBar>
           </ext:FormPanel>
          </Items>              
       </ext:Viewport>
    </form>
    <ext:XScript ID="XScript1" runat="server">
        <script type="text/javascript">
          
            var pgFn = new Object();
            pgFn._id = "pnlContentUrlDinamic";
            pgFn.myPanel = null;
            pgFn.ClosePgAdmGlobal = function () {              
                 App.direct.DataBindGrid({
                     success: function (result) {
                         
                     },
                     eventMask: {
                         showMask: true,
                         minDelay: 500
                     }
                 });              
            };
            pgFn.ShowActivarUsuario = function () {
                var winUrl = AppGlobalJs.mostrarVentanaUrl('pgActivarUsuarios.aspx', 'Activar Usuario Promotor', null);
                winUrl.addListener('close', function (el) { pgFn.ClosePgAdmGlobal(); el.destroy(); });

            };
            pgFn.setParameDinamic = function () {
              
            };
            pgFn.getIdContentDinamic = function () {
                return (pgFn._id);
            };
            //Vizualizar panel detalle
            pgFn.cargarTabNewUser = function (item, menuItem, e) {
                var myUrl = menuItem.url + "&idPage=" + App.hddIdPageSession.getValue();               
                App.tab1FrmDetail.setTitle("Usuario " + menuItem.text);
                App.direct.SetSession("NUEVO", {
                    success: function (result) {
                        App.frmSettings.collapse();
                        App.frmSettings.hide();
                        App.frmDetail.show();
                        var myPanelContent = App.tab1FrmDetail;
                        pgFn.myPanel = myPanelContent.add(new Ext.Panel({
                            id: pgFn.getIdContentDinamic(),
                            border: false,
                            anchor: '100% 100%',
                            loader:
                             {
                                 loadMask:
                                     {
                                         showMask: true
                                     },
                                 renderer: "frame",
                                 url: myUrl
                             },
                            bodyPadding: 6,
                            closable: false,

                        }));
                        App.frmDetail.getForm().reset();
                     },
                    eventMask: {
                        showMask: true,
                        minDelay: 500
                    }
                });

            };
            //Cerrar panel detalles
            pgFn.ClosePanel = function () {
             
                var myPanelContent = App.tab1FrmDetail;
                //Creacion del tab
                if (pgFn.myPanel != null) {
                    myPanelContent.remove(pgFn.getIdContentDinamic(), false);
                    pgFn.myPanel = null;
                }
                App.frmDetail.hide();
                App.frmSettings.expand();
                App.frmSettings.show();
                App.frmDetail.getForm().reset();
               
               
            };
            //Ocultar panel 
            pgFn.ActivarUsuarioPanel = function () {
                window.parent.frames[0].App.frmSettings.hide();
            }
            //Mostrar panel detalles, para modificar
            pgFn.ShowViewDetailPanel = function (record,myEvento) {
                var codeRowRol = record.get("RolCodigo");
                var myUrl = "";
                
                if (codeRowRol == App.hddRolCodigoDirector.getValue()) {
                    App.tab1FrmDetail.setTitle("Usuario Director");
                    myUrl = "pgAdmin.aspx?CodeRol=" + App.hddRolCodigoDirector.getValue() + "&idPage=" + App.hddIdPageSession.getValue() + "&idx1=" + record.get("PersonaId") + "&idx2=" + record.get("Id") ;
                }

                if (codeRowRol == App.hddRolCodigoSubDirector.getValue()) {
                    App.tab1FrmDetail.setTitle("Usuario Sub-Director");
                    myUrl = "pgAdmin.aspx?CodeRol=" + App.hddRolCodigoSubDirector.getValue() + "&idPage=" + App.hddIdPageSession.getValue() + "&idx1=" + record.get("PersonaId") + "&idx2=" + record.get("Id");
                }

                if (codeRowRol == App.hddRolCodigoPromotor.getValue()) {
                    App.tab1FrmDetail.setTitle("Usuario Promotor");
                    myUrl = "pgPromotor.aspx?idPage=" + App.hddIdPageSession.getValue() + "&idx1=" + record.get("PersonaId") + "&idx2=" + record.get("Id");
                }
             
                if (codeRowRol == App.hddRolCodigoPromotor.getValue()) {
                    App.tab1FrmDetail.setTitle("Usuario Promotor");
                    myUrl = "pgPromotor.aspx?CodeRol=" + App.hddRolCodigoPromotor.getValue() + "&idPage=" + App.hddIdPageSession.getValue() + "&idx1=" + record.get("PersonaId") + "&idx2=" + record.get("Id");
                }
                if (codeRowRol == App.hddRolCodigoTecnico.getValue() || codeRowRol == App.hddRolCodigoTecnicoL.getValue()) {
                    App.tab1FrmDetail.setTitle("Usuario Técnico");
                    myUrl = "pgTecnico.aspx?idPage=" + App.hddIdPageSession.getValue() + "&idx1=" + record.get("PersonaId") + "&idx2=" + record.get("Id");
                }
                if (codeRowRol == App.hddRolCodigoAdminis.getValue()) {
                    App.tab1FrmDetail.setTitle("Usuario Administrador");
                    myUrl = "pgAdmin.aspx?idPage=" + App.hddIdPageSession.getValue() + "&idx1=" + record.get("PersonaId") + "&idx2=" + record.get("Id");
                }
                if (codeRowRol == App.hddRolCodigoJefe.getValue() || codeRowRol == App.hddRolCodigoJefeL.getValue()) {
                    App.tab1FrmDetail.setTitle("Usuario Jefe Departamental");
                    myUrl = "pgJefeDep.aspx?idPage=" + App.hddIdPageSession.getValue() + "&idx1=" + record.get("PersonaId") + "&idx2=" + record.get("Id");
                }
                if (codeRowRol == App.hddRolCodigoConsultor.getValue()) {
                    App.tab1FrmDetail.setTitle("Usuario Consultor");
                    myUrl = "pgConsultor.aspx?idPage=" + App.hddIdPageSession.getValue() + "&idx1=" + record.get("PersonaId") + "&idx2=" + record.get("Id");
                }
                //
                App.direct.SetSession(myEvento, {
                    success: function (result) {
                        App.frmSettings.collapse();
                        App.frmSettings.hide();
                        App.frmDetail.show();
                        var myPanelContent = App.tab1FrmDetail;
                        pgFn.myPanel = myPanelContent.add(new Ext.Panel({
                            id: pgFn.getIdContentDinamic(),
                            border: false,
                            anchor: '100% 100%',
                            loader:
                             {
                                 loadMask:
                                     {
                                         showMask: true
                                     },
                                 renderer: "frame",
                                 url: myUrl
                             },
                            bodyPadding: 6,
                            closable: false,

                        }));
                        App.frmDetail.getForm().loadRecord(record);

                    },
                    eventMask: {
                        showMask: true,
                        minDelay: 500
                    }
                });

          
            };
            //Vizualiza iconos grid segun estado
            pgFn.PrepareCommandGrid = function (grid, command, record, row) {

                var codeRol = App.hddRolCodigoPromotor.getValue();
                var codeRowRol    = record.get("RolCodigo");
                var codeRowEstado = record.get("Estado");
                if (command.command == 'CmdText' && codeRol == codeRowRol) {
                    command.hidden = false;
                    command.hideMode = 'visibility';
                    if (codeRowEstado!='')
                    {
                        var codeRowEstadoString = new String(codeRowEstado);
                        command.text=codeRowEstadoString.capitalize();
                        switch (codeRowEstado) {
                            case "ACTIVO":
                                command.iconCls='icon-usertick';
                                break;
                            case "INACTIVO":
                                command.iconCls='icon-useralert';
                                break;
                            default:
                                command.iconCls='icon-groupgo';
                                break;
                        }

                    }
                    else
                    { 
                        command.iconCls='';
                        command.text='';
                    }
                    
                }
                else
                {
                    command.hidden = true;
                    command.hideMode = 'display'; //ocultar
                }
                if (codeRol == codeRowRol)
                    codeRowEstado = "";
                if (command.command == 'CmdActivo') {

                    switch (codeRowEstado) {
                        case "ACTIVO":
                           
                            command.hidden = false;
                            command.hideMode = 'visibility';
                            break;

                        default:
                            command.hidden = true;
                            command.hideMode = 'display'; //ocultar
                            break;
                    }
                }
                if (command.command == 'CmdDesactivo') {
                    switch (codeRowEstado) {
                        case "INACTIVO":
                            command.hidden = false;
                            command.hideMode = 'visibility';
                            break;

                        default:
                            command.hidden = true;
                            command.hideMode = 'display'; //you can try 'visibility' also 
                            break;
                    }

                }
              

            };
            //Actualiza estado de usuario
            pgFn.ImageCommandUdpateEstado = function (cmd,data) {
                if(cmd=='CmdActivo'|| cmd=='CmdDesactivo')
                {
                    App.direct.UpdateEstadoUser(data.Id, data.Estado, {
                        success: function (result) {
                       
                    },
                        eventMask: {
                        showMask: true,
                        minDelay: 500
                    }
                    });
                }
            };
            //Actualiza grid de datos de usuario y cierra panel de datos principal
            pgFn._closeWinUserNew = function () {
                App.direct.DataBindGrid({
                    success: function (result) {
                        pgFn.ClosePanel();
                    },
                    eventMask: {
                        showMask: true,
                        minDelay: 500
                    }
                });
            };
            //Vizualiza alerta,cierra panel principal y actualiza grid de datos de usuario
            App.ViewGrid = function (txtMsg)
            {
                Ext.Msg.show({
                    title: 'Aviso',
                    msg: txtMsg,
                    buttons: Ext.Msg.OK,
                    fn: pgFn._closeWinUserNew,
                    animEl: 'elId'
                });

            };
       </script>
    </ext:XScript>     
</body>


</html>
